package com.example.controller;


import com.example.base.config.CaptureConfig;
import com.wf.captcha.SpecCaptcha;
import com.wf.captcha.base.Captcha;
import com.wf.captcha.utils.CaptchaUtil;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Api(tags = "验证码管理")
@CrossOrigin
@RestController
@RequestMapping
public class CaptureController {

    @RequestMapping("/captcha")
    public void captcha(@RequestParam String key,HttpServletRequest request, HttpServletResponse response)throws Exception{
        SpecCaptcha captcha=new SpecCaptcha(135,40,5);
        captcha.setCharType(Captcha.TYPE_NUM_AND_UPPER);
        //保存验证码,存在后台Map里面
        CaptureConfig.CAPTURE_MAP.put(key,captcha.text().toLowerCase());
        CaptchaUtil.out(captcha,request,response);

    }
}
